import {RouteRecordRaw} from "vue-router"
import Layout from "@/layouts/layout-index.vue"
import {$t} from "@/locales";

// $t() 用于 Vue 组件，在任何 Vue 单文件组件中，统一使用 $t()
// t() 适用于非 Vue 组件的场景。在任何 .ts 文件中，统一使用 t()
// 要想在 ts 文件中使用 t 目前只知道如下方法，在 ts 文件中导入我们暴露的 i18n 实例，然后从中解构出 global
// TODO 为了和 Vue 组件的 $t() 保持一致，将接受的变量名改为 $t 而不是 t
// const $t = i18n.global.t;

/**
 * 定义layout页面路由（默认静态路由）
 * 前端添加路由，请在此处加，每天加一个layout布局下的views目录下的vue文件
 */
export const dynamicRoutes: Array<RouteRecordRaw> = [
    // 首页
    {
        path: '/',
        name: 'Home',
        component: Layout,
        redirect: '/dashboard',
        meta: {
            icon: "ep:home-filled",
        },
        children: [
            {
                path: '/dashboard',
                name: 'Dashboard',
                component: () => import('@/views/dashboard/index.vue'),
                meta: {
                    title: "首页",
                    icon: 'HomeFilled',
                    transition: 'slide-left',
                    requiresAuth: false,
                },
            },
        ],
    },

    // 用户管理
    {
        path: '/user',
        name: 'User',
        component: Layout,
        meta: {
            title: "用户管理",
            icon: 'UserFilled',
        },
        children: [
            {
                path: '/user/info',
                name: 'Info',
                component: () => import('@/views/user/info.vue'),
                meta: {
                    title: "个人中心",
                },
            },
            {
                path: '/user/account',
                name: 'Account',
                component: () => import('@/views/user/account.vue'),
                meta: {
                    title: "账号管理",
                },
            },
            {
                path: '/user/role',
                name: 'Role',
                component: () => import('@/views/user/role.vue'),
                meta: {
                    title: "角色管理",
                },
            },
        ],
    },

    // 异常页面路由
    {
        path: '/error',
        name: 'Error',
        component: Layout,
        meta: {
            title: '异常页面',
            icon: 'UserFilled',
            keepAlive: true
        },
        children: [
            {
                path: '/error/403',
                name: '403',
                component: () => import('@/views/error/403.vue'),
                meta: {
                    title: "403",
                },
            },
            {
                path: '/error/404',
                name: 'staticRoutes.notFound',
                component: () => import('@/views/error/404.vue'),
                meta: {
                    title: "404",
                },
            },
            {
                path: '/error/500',
                name: '500',
                component: () => import('@/views/error/500.vue'),
                meta: {
                    title: "500",
                },
            },
        ],
    },

    // 结果页面路由
    {
        path: '/result',
        name: 'Result',
        component: Layout,
        meta: {
            title: '结果页面',
            icon: 'UserFilled',
            keepAlive: true
        },
        children: [
            {
                path: '/result/success',
                name: 'Success',
                component: () => import('@/views/result/success.vue'),
                meta: {
                    title: "成功页面",
                },
            },
            {
                path: '/result/fail',
                name: 'Fail',
                component: () => import('@/views/result/fail.vue'),
                meta: {
                    title: "失败页面",
                },
            },
        ],
    },

];

/**
 * 定义静态非layout路由（登录、注册、404、401错误异常等基础路由）
 */
export const staticRoutes: Array<RouteRecordRaw> = [
    {
        path: '/login/normal',
        name: 'normal.login',
        component: () => import('@/views/login/normal/LoginNormal.vue'),
        meta: {
            hidden: true,
            requiresAuth: false,
        },
    },
    {
        path: '/login/glass',
        name: 'glass.login',
        component: () => import('@/views/login/glass/LoginGlass.vue'),
        meta: {
            hidden: true,
            requiresAuth: false,
        },
    },
    {
        path: '/register/normal',
        name: 'normal.register',
        component: () => import('@/views/login/normal/RegisterNormal.vue'),
        meta: {
            hidden: true,
            requiresAuth: false,
        },
    },
    {
        path: '/register/glass',
        name: 'glass.register',
        component: () => import('@/views/login/glass/RegisterGlass.vue'),
        meta: {
            hidden: true,
            requiresAuth: false,
        },
    },
];